-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not cancel stripe subscription in case of failed payment #8285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite follow why we are still canceling subscriptions on first failed payment? I thought the test case 1 is what's happening today and we want to change against it?
const subscriptionObject = await manager.retrieveSubscription(stripeSubscriptionId) | ||
|
||
if (subscriptionObject.status === 'incomplete' || subscriptionObject.status === 'canceled') { | ||
// Terminate subscription if it is the first failed payment, or it is already canceled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why terminate the subscription on 1st failed payment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tianrunhe I keep what is happening today only for case 1:
User setup the subscription for the first time, he adds a card but then almost immediately first payment fails.
I keep this for two reasons:
- I think it is safe to cancel subscription in this case.
- Stripe documentation suggest to cancel such subscriptions if no payment was made within 23 hours.
To not handle this 23 hours case specifically I think it is easier to just cancel right now:
Payment window
Customers have about 23 hours to make a successful payment. The subscription remains in status incomplete and the invoice is open during this time. If your customer pays the invoice, the subscription updates to active and the invoice to paid. If they don't make a payment, the subscription updates to incomplete_expired and the invoice becomes void.This window exists because your customer usually makes the first payment for a subscription while on-session. If the customer returns to your application after 23 hours, create a new subscription for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added more comments in code. What do you think?
I don't like that it cancels the subscription and locks the team immediately, for 3DS card (test card number: |
@tianrunhe I think the case with 3D secure card is no different from 3D secure card will always fail because we don't have 3D secure card support implemented. For 1st payment it is safe to cancel subscription, because the initial issue is only about canceling already existing subscription with existing past payments — "unpaid balances failing to carry forward"
What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good then!
Ooooo this is some tricky stuff, thank you for tackling it! So as I understand the business logic, we cancel the subscription in stripe if it has been alive for < 1 day (failed payment, delayed failed payment). If a subsequent payment fails (e.g. CC canceled/expired) then we lock them out of their team, but keep the subscription running. That means if it takes them a month to update their CC, they owe us for that month even though they haven't used us. Is that OK? Not saying it's good or bad, just want to make sure that's the intended effect. Code ReviewWe use
|
Yes, we cancel subscription if it is in
Yes, this is the expected behavior at this time. We want to improve by giving some period before locking the org, andonly then cancel the subscription: #8341
Thanks! This seems to be the only case. Fixed! |
Fix #8166
I changed the following subscriptions settings on stripe, it should not affect prod, as we currently terminate subscriptions from the code on failed payments anyway:
How to test:
Case 1:
4000000000000341
card (It will fail later after upgrade)4242 4242 4242 4242
active
subscription was createdCase 2:
// trial_end: toEpochSeconds(new Date(Date.now() + 1000 * 10))
, increateTeamSubscription
4242 4242 4242 4242
active
, no new subscription created, invoice is paid